package com.youdoneed.friends.common.util;


import com.youdoneed.friends.vo.LostChildVo;

import net.sf.json.JSONArray;
import java.io.*;
import java.util.List;


/**
 * Created by Administrator on 2017/12/18 0018.
 */
public class FileUtil {

    /*public static void main(String args[]) {
        String str = FileUtil.ReadFile("D:\\失踪儿童数据\\demo.json");
        System.out.println(str);

        List<LostChildVo> list = (List<LostChildVo>) JSONArray.toList(JSONArray.fromObject(str), LostChildVo.class);
        if((null != list)
                &&(0 < list.size())){
            System.out.println(list.size());
            for(LostChildVo vo : list){
                System.out.println(vo.getName());
            }
        }
    }*/

    public static String ReadFile(String path) {
        String laststr = "";
        File file = new File(path);// 打开文件
        BufferedReader reader = null;
        try {
            FileInputStream in = new FileInputStream(file);
            reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));// 读取文件
            String tempString = null;
            while ((tempString = reader.readLine()) != null) {
                laststr = laststr + tempString;
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (reader != null) {
                try {
                    reader.close();
                } catch (IOException el) {
                }
            }
        }
        return laststr;
    }
}
